//
//  ProjectSeletedCollectionViewCell.m
//  XiaoMiao
//
//  Created by kinglian_iOS_000 on 2018/1/30.
//  Copyright © 2018年 smallyou. All rights reserved.
//

#import "ProjectSeletedCollectionViewCell.h"
#import "ProjectSeletedModel.h"

@interface ProjectSeletedCollectionViewCell ()
@property (weak, nonatomic) IBOutlet UIButton *tagButton;

@end

@implementation ProjectSeletedCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.item = -1;
    
    [self.tagButton addTarget:self action:@selector(tagButtonDidClick) forControlEvents:UIControlEventTouchUpInside];
}

- (void)setProjectSeletedModel:(ProjectSeletedModel *)projectSeletedModel {
    _projectSeletedModel = projectSeletedModel;
    
    [self.tagButton setTitle:projectSeletedModel.name forState:UIControlStateNormal];
    self.tagButton.selected = projectSeletedModel.isTagSeleted;
}

- (void)tagButtonDidClick {
    if (self.item == -1 || self.tagButton.isSelected) {
        return;
    } 
    
    if ([self.delegate respondsToSelector:@selector(projectSeletedCollectionViewCell:seletedItem:)]) {
        [self.delegate projectSeletedCollectionViewCell:self seletedItem:self.item];
    }
}

+ (NSString *)cellId {
    return @"_kProjectSeletedCollectionViewCellId_";
} 

+ (CGSize)cellSize {
    return CGSizeMake(kScreenWidth * 1.0 / 3.0 - 0.05, 54.f);
}

@end
